//
//  MeatMineBlankView.m
//  PigMarket
//
//  Created by 张敬 on 2019/8/27.
//  Copyright © 2019年 pigmarket.oc. All rights reserved.
//

#import "MeatMineBlankView.h"

@implementation MeatMineBlankView

#pragma mark - lifecycle methods

- (void)setupUI{
    
    self.backgroundColor = mBackgroudColor;
    [self addSubview:self.messageLogo];
    [self addSubview:self.messageLab];
    [self addSubview:self.messageBtn];
}

- (void)setupLayout
{
    self.height = 275;
    self.width = KScreenWidth;
    self.mj_x = 0;
    self.mj_y = 0;
    
    {
        _messageLogo.width = 158;
        _messageLogo.height = 132;
        _messageLogo.mj_y = 0;
        _messageLogo.mj_x = (self.width - _messageLogo.width)/2.0;

    }
    
    {
        _messageLab.mj_y = _messageLogo.bottom + 20;
        _messageLab.mj_x = 0;
        _messageLab.width = self.width;
        _messageLab.height = 36;
    }
    
    {
        _messageBtn.mj_y = _messageLab.bottom + 51;
        _messageBtn.mj_x = (self.width - 126)/2.0;
        _messageBtn.width = 126;
        _messageBtn.height = 36;
    }
}

#pragma mark - setter methods

- (void)setType:(MeatMineBlankViewType)type{
    
    _type = type;
    switch (type) {
        case MeatMineBlankViewType_Adopt:
            {
                NSString *text = @"您未领养小猪暂无法开通\n家中有铺又有田，养几头猪赚点钱，生活乐无边";
                _messageLab.text = text;
                [_messageBtn setTitle:@"去领养" forState:UIControlStateNormal];
            }
            break;
            
        default:
            {
                NSString *text = @"您未开通肉铺\n请您开通肉铺，做起老板吧！";
                _messageLab.text = text;
                [_messageBtn setTitle:@"开通肉铺" forState:UIControlStateNormal];

            }
            break;
    }
}

#pragma mark - getter methods

- (UIImageView *)messageLogo{
    
    if (!_messageLogo) {
        _messageLogo = [[UIImageView alloc] init];
        _messageLogo.image = [UIImage imageNamed:@"meat_shop_blank"];
    }
    return _messageLogo;
}

- (UILabel *)messageLab{
    
    if (!_messageLab) {
        
        _messageLab = [UILabel makeLabelWithText:@"" textColor:UIColorFromRGB(0xB0B0B0) font:mFont(13) textAliment:1];
        _messageLab.numberOfLines = 0;
    }
    return _messageLab;
}


- (UIButton *)messageBtn{
    
    if (!_messageBtn) {
        _messageBtn = [UIButton makeButtonWithText:@"" textColor:KWhiteColor font:mFont(14) textAliment:1 cornerRadius:18];
        [_messageBtn setBackgroundImage:[UIImage imageNamed:@"meat_cart_pay_right"] forState:UIControlStateNormal];
        
        @weakify(self);
        _messageBtn.tapBlock = ^{
            @strongify(self);
            if (self.dealJumpBlock) {
                
                NSInteger type = self.type == MeatMineBlankViewType_Adopt ?1: 2;
                self.dealJumpBlock(type);
            }
        };
    }
    return _messageBtn;
}


@end
